home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / lh211src.zip / _CNVTIME.ASM next >
Assembly Source File  |  1991-03-03  |  3KB  |  179 lines

  1. ;***********************************************
  2. ;    _cnvtime.asm -- replacement of LSI C-86
  3. ;                    run time library routine
  4. ;***********************************************
  5.             page    0, 128
  6.  
  7. include    amscls.inc
  8. $_init    GEN
  9.  
  10. LHA        =        1
  11.  
  12. CGROUP    GROUP    TEXT
  13. DGROUP    GROUP    DATA,BSS
  14.         assume    cs:CGROUP, ds:DGROUP, ss:DGROUP
  15.  
  16. TEXT    segment byte public 'CODE'
  17. TEXT    ends
  18.  
  19. DATA    segment word public 'DATA'
  20. DATA    ends
  21.  
  22. BSS        segment word public 'DATA'
  23. BSS        ends
  24.  
  25. tm    struc
  26.     tm_sec        dw        1 dup (?)
  27.     tm_min        dw        1 dup (?)
  28.     tm_hour        dw        1 dup (?)
  29.     tm_mday        dw        1 dup (?)
  30.     tm_mon        dw        1 dup (?)
  31.     tm_year        dw        1 dup (?)
  32.     tm_wday        dw        1 dup (?)
  33.     tm_yday        dw        1 dup (?)
  34.     tm_isdst    dw        1 dup (?)
  35. tm    ends
  36.  
  37. DATA    segment word public 'DATA'
  38. daysmonth    label    word
  39. m3        dw        31
  40. m4        dw        30
  41. m5        dw        31
  42. m6        dw        30
  43. m7        dw        31
  44. m8        dw        31
  45. m9        dw        30
  46. m10        dw        31
  47. m11        dw        30
  48. m12        dw        31
  49. m1        dw        31
  50. m2        dw        29
  51. DATA    ends
  52.  
  53. TEXT    segment byte public 'CODE'
  54.             public    _convtime_
  55. _convtime_    proc    near
  56.     push    cx
  57.     push    dx
  58.     push    si
  59.     push    di
  60.     mov        si, ax
  61.  
  62.     mov        di, 60
  63.     mov        ax, [bx + 2]
  64.     xor        dx, dx
  65.     div        di
  66.     mov        cx, ax
  67.     mov        ax, [bx]
  68.     div        di                    ; cx:ax
  69.     mov        tm_sec[si], dx
  70.  
  71.     xchg    ax, cx
  72.     xor        dx, dx
  73.     div        di
  74.     xchg    ax, cx
  75.     div        di                    ; cx:ax
  76.     mov        tm_min[si], dx
  77.  
  78.     mov        di, 24
  79.     xchg    ax, cx
  80.     xor        dx, dx
  81.     div        di
  82.     xchg    ax, cx
  83.     div        di                    ; cx:ax
  84.     mov        tm_hour[si], dx
  85.  
  86.     mov        cx, ax
  87.     xor        dx, dx
  88.     mov        di, 7
  89.     div        di
  90.     mov        tm_wday[si], dx
  91.     mov        ax, cx
  92.  
  93.     mov        cx, 68
  94.                                         ; adjust to 1968-3-1
  95.     $_if <add ax, 365 * 2 - 31 - 28>, C, OR
  96.     $_c  <cmp ax, 365 * 32 + 8>, AE
  97.         sub        ax, 365 * 32 + 8        ; adjust to 2000-3-1
  98.         mov        cx, 100
  99. if 0
  100.         xor        dx, dx
  101.         mov        di, 365 * 400 + 97
  102.         div        di
  103.         push    dx
  104.         mov        di, 400
  105.         mul        di
  106.         add        cx, ax
  107.         pop        ax
  108. endif
  109.         xor        dx, dx
  110.         mov        di, 365 * 100 + 24
  111.         div        di
  112.         push    dx
  113.         mov        di, 100
  114.         mul        di
  115.         add        cx, ax
  116.         pop        ax
  117.     $_endif
  118.     xor        dx, dx
  119.     mov        di, 365 * 4 + 1
  120.     div        di
  121.     shl        ax, 1
  122.     shl        ax, 1
  123.     add        cx, ax
  124.  
  125.     mov        di, 365
  126.     mov        ax, dx
  127.     xor        dx, dx
  128.     div        di
  129.     $_if <cmp ax, 4>, AE
  130.         dec        ax
  131.         add        dx, di
  132.     $_endif
  133.     add        ax, cx
  134. ifndef LHA
  135.     mov        bx, dx
  136.     add        bx, 31 + 28
  137. endif
  138.     mov        cx, 2
  139.     mov        di, offset DGROUP:daysmonth
  140.     $_while <sub dx, [di]>, AE
  141.         inc        di
  142.         inc        di
  143.         inc        cx
  144.     $_enddo
  145.     add        dx, [di]
  146. ifndef LHA
  147.     $_if <cmp cx, 12>, AE
  148.         inc        ax
  149.         sub        cx, 12
  150.         sub        bx, 365
  151.     $_else
  152.         $_if <test ax, 3>, Z
  153.             inc        bx
  154.         $_endif
  155.     $_endif
  156. else
  157.     $_if <cmp cx, 12>, AE
  158.         inc        ax
  159.         sub        cx, 12
  160.     $_endif
  161. endif
  162.  
  163.     inc        dx
  164.     mov        tm_mday[si], dx
  165.     mov        tm_mon[si], cx
  166.     mov        tm_year[si], ax
  167. ifndef LHA
  168.     mov        tm_yday[si], bx
  169. endif
  170.     pop        di
  171.     pop        si
  172.     pop        dx
  173.     pop        cx
  174.     ret
  175. _convtime_    endp
  176. TEXT    ends
  177.  
  178.         end
  179.